Skip to content

REF: remove putmask_preserve, putmask_without_repeat #44328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 6, 2021

Conversation

jbrockmendel
Copy link
Member

No longer needed following #44275

@jreback jreback added Indexing Related to indexing on series/frames, not to indexes themselves Refactor Internal refactoring of code labels Nov 6, 2021
@jreback jreback added this to the 1.4 milestone Nov 6, 2021
@jreback jreback merged commit 0861da6 into pandas-dev:master Nov 6, 2021
@jbrockmendel jbrockmendel deleted the ref-putmasks-2 branch November 6, 2021 19:43
@phofl
Copy link
Member

phofl commented Nov 6, 2021

This one broke test_where_axis with

pandas/tests/frame/indexing/test_where.py:456 (TestDataFrameIndexingWhere.test_where_axis)
self = <pandas.tests.frame.indexing.test_where.TestDataFrameIndexingWhere object at 0x7f378663f250>

    def test_where_axis(self):
        # GH 9736
        df = DataFrame(np.random.randn(2, 2))
        mask = DataFrame([[False, False], [False, False]])
        s = Series([0, 1])
    
        expected = DataFrame([[0, 0], [1, 1]], dtype="float64")
        result = df.where(mask, s, axis="index")
        tm.assert_frame_equal(result, expected)
    
        result = df.copy()
        return_value = result.where(mask, s, axis="index", inplace=True)
        assert return_value is None
        tm.assert_frame_equal(result, expected)
    
        expected = DataFrame([[0, 1], [0, 1]], dtype="float64")
        result = df.where(mask, s, axis="columns")
        tm.assert_frame_equal(result, expected)
    
        result = df.copy()
        return_value = result.where(mask, s, axis="columns", inplace=True)
        assert return_value is None
        tm.assert_frame_equal(result, expected)
    
        # Upcast needed
        df = DataFrame([[1, 2], [3, 4]], dtype="int64")
        mask = DataFrame([[False, False], [False, False]])
        s = Series([0, np.nan])
    
        expected = DataFrame([[0, 0], [np.nan, np.nan]], dtype="float64")
        result = df.where(mask, s, axis="index")
        tm.assert_frame_equal(result, expected)
    
        result = df.copy()
        return_value = result.where(mask, s, axis="index", inplace=True)
        assert return_value is None
        tm.assert_frame_equal(result, expected)
    
        expected = DataFrame([[0, np.nan], [0, np.nan]])
        result = df.where(mask, s, axis="columns")
        tm.assert_frame_equal(result, expected)
    
        expected = DataFrame(
            {
                0: np.array([0, 0], dtype="int64"),
                1: np.array([np.nan, np.nan], dtype="float64"),
            }
        )
        result = df.copy()
>       return_value = result.where(mask, s, axis="columns", inplace=True)

test_where.py:506: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../../util/_decorators.py:311: in wrapper
    return func(*args, **kwargs)
../../../core/frame.py:10912: in where
    return super().where(cond, other, inplace, axis, level, errors, try_cast)
../../../core/generic.py:9196: in where
    return self._where(cond, other, inplace, axis, level, errors=errors)
../../../core/generic.py:9030: in _where
    new_data = self._mgr.putmask(mask=cond, new=other, align=align)
../../../core/internals/managers.py:348: in putmask
    return self.apply(
../../../core/internals/managers.py:305: in apply
    applied = getattr(b, f)(**kwargs)
../../../core/internals/blocks.py:996: in putmask
    rbs = nb.putmask(submask, n)
../../../core/internals/blocks.py:963: in putmask
    np.putmask(self.values.T, mask, new)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (array([[1],
       [3]]), array([[ True],
       [ True]]), array([[0.],
       [0.]]))
kwargs = {}
relevant_args = (array([[1],
       [3]]), array([[ True],
       [ True]]), array([[0.],
       [0.]]))

>   ???
E   TypeError: Cannot cast array data from dtype('float64') to dtype('int64') according to the rule 'safe'

@jbrockmendel
Copy link
Member Author

Darn. OK let's revert and i'll try again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Indexing Related to indexing on series/frames, not to indexes themselves Refactor Internal refactoring of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants